<?php
namespace Admin\Controller;
/**
 * author:huhaiqin
 * time:2019-12-10 
 * feature:配置文件管理
 */
class ConfigController extends CommonController{

    /**
     * 配置列表
     */
    public function index(){
        $this->display();
    }

    public function getdata(){
        //如果api_table = 0,则表示正常的_apiReturn接口
        if($_REQUEST['api_table'] == '' || $_REQUEST['api_table'] != 0){
            C('api_table',true); //标注是apitable的接口返回
        }
        $p = I('page') ? I('page') : 1;
        $row = I('limit') ? I('limit') : 10;
        $query = '';
        if($_GET['searchtype'] && $_GET['keywords']){
            $query .= ' AND '.$_GET['searchtype'].' like "%'.$_GET['keywords'].'%"';
        }
        $m = D('Config');
        $data = $m->_query($p,$row,$query);
        _apiReturn(1,'success',$data);
    }

    /**
     * 显示数据
     */
    public function show(){
        $this->info = D('Config')->find(I('id'));
        $this->display();
    }

    public function edit_post(){
        $m = D('Config');
        $m->edit($_REQUEST);
    }


    public function del(){
        $this->_del(D('Config'),I('ids'));
    }

    /**
     * 本地学校设置
     */
    public function set_school(){
        $m = D('Config');
        $this->info = $m->_find_by_key('school');
        $this->display();
    }

    /**
     * 站点设置
     */
    public function set_site(){
        $m = D('Config');
        $this->info = $m->_find_by_key('site');
        $this->display();
    }

    /**
     * 站点设置
     */
    public function set_email(){
        $m = D('Config');
        $this->info = $m->_find_by_key('email');
        $this->display();
    }

    /**
     * 存储设置，七牛云啊，本地存储啊
     */
    public function set_save(){
        $m = D('Config');
        $this->info = $m->_find_by_key('save');
        $this->display();
    }

    /**
     * 积分规则列表
     */
    public function jifen(){
        $this->display();
    }

    /**
     * 编辑积分规则
     */
    public function jifen_edit(){
        if($_GET['id']){
            $this->info = D('Jifen')->find($_GET['id']);
        }
        $this->display();
    }

    /**
     * description 静态缓存管理
     */
    public function cache_manage(){
        $this->display();
    }
    public function clean_home_cache(){
        D('Config')->_clean_home_cache();
    }

    /**
     * 微信公众号设置
     */
    public function set_wx(){
        $m = D('Config');
        $this->info = $m->_find_by_key('wechat');
        $this->display();
    }

    /**
     * 20200922，haiqin，重置密码
     */
    public function repwd(){
        $this->display();
    }

    /**
     * 2022.05.23 huhaiqin,修改头像
     */
    public function avatar(){
        C('LAYOUT_NAME','layout_admin');
        $this->display('User@Admins:avatar');
    }

    /**
     * 2023.3.15 huhaiqin ，修改用户地址信息
     */
    public function address(){
        C('LAYOUT_NAME','layout_admin');
        $this->info = $_SESSION['loginUser'];
        $this->display('User@Admins:address');
    }

    /**
     * 2023.3.15 huhaiqin， 修改个人介绍
     */
    public function selfinfo(){
        C('LAYOUT_NAME','layout_admin');
        $this->info = $_SESSION['loginUser'];
        $this->display('User@Admins:selfinfo');
    }

    
}